<template>
	<view>

		<view class="content_item" v-for="(item,index) in activityinfo" :key="index">

			<!-- ======================================== -->

			<view class="cu-card article" :class="isCard?'no-card':''">
				<view class="cu-item shadow">
					<view class="title">
						<view class="text-cut">{{item.activityname}}</view>
					</view>
					<view class="content">
						<!-- <image src='../../static/ganjiang.png' -->
						<image :src="item.imagePath[0]" mode="aspectFill"></image>
						<view class="desc">
							<view class=".topic_cont_text text-gray" style="margin: 10rpx;">
								{{item.detailCout}}
							</view>

							<!-- <view>
								<view class="cu-tag bg-red light sm round">王者荣耀</view>
								<view class="cu-tag bg-green light sm round">苏烈</view>
								
							</view> -->
							<!-- 这里要加一个按钮 -->
							<button @click="toDetail(item.activityname)" class="cu-btn padding radius text-center light bg-olive ">活动详情</button>
						</view>
					</view>
				</view>
			</view>



		</view>
		<!-- ======================================== -->
		<down-block></down-block>
	</view>
	</view>
</template>

<script>
	import customTarbar from '@/wxcomponents/custom-tarbar/custom-tarbar.vue';
	import cuCustom from '../../colorui/components/cu-custom.vue'
	import downBlock from '../../components/down_block.vue'
	export default {
		components: {
			'custom-tarbar': customTarbar,
			cuCustom,
			downBlock
		},
		data() {
			return {
				isCard: false,
				activityinfo: [],
			}
		},
		methods: {
			manageActByName(activityName){
				uni.navigateTo({
					url:'../user/participated?activityname='+activityName
				})
			},
			async getDetail(){
				let username=JSON.parse(uni.getStorageSync("USERS_KEY")).username
				const baseurl=getApp().globalData.BASE_URL
				let inner=this
				uni.request({
					url:baseurl+'/user/participated?username='+username,
					method:"POST",
					success(res) {
						inner.activityinfo=res.data;
						// 对图片的url进行遍历修改
						for(let j=0;j<inner.activityinfo.length;j++){	
							for(let i=0;i<inner.activityinfo[j].imagePath.length;i++){
								if(inner.activityinfo[j].imagePath[i].indexOf("http")==-1){
									// 如果图片url里面没有http字体那边加上baseurl
									inner.activityinfo[j].imagePath[i]=baseurl+inner.activityinfo[j].imagePath[i];
								}
							}
						}
					}
				})
				// const res = await this.$myRequest({
				// 	url:'/user/participated?username='+username,
				// 	// data:{
				// 	// 	username:username
				// 	// },
				// 	method:"POST"
					
					
				// })
				// console.log(res)
				// this.activityinfo=res.data;
				// // 对图片的url进行遍历修改
				// for(let j=0;j<this.activityinfo.length;j++){	
				// 	for(let i=0;i<this.activityinfo[j].imagePath.length;i++){
				// 		if(this.activityinfo[j].imagePath[i].indexOf("http")==-1){
				// 			// 如果图片url里面没有http字体那边加上baseurl
 			// 				this.activityinfo[j].imagePath[i]=baseurl+this.activityinfo[j].imagePath[i];
				// 		}
				// 	}
				// }
				// console.log("修改后的url",this.activityinfo)
			},
			toDetail(name) {
				uni.navigateTo({
					url: '../detail/detail?name=' + name
				})
			},
		},
		onLoad() {
			this.getDetail()
		},
		onShow() {
			//获取数据
			console.log(this.activityinfo)
		}
	}
</script>

<style>

</style>
